<template>
  <div class="content">
    <img :src="bkImg" alt="全国数码防伪中心" class="bk" srcset="">

    <div class="success">
      <div class="title" v-if="success==1">
        尊敬的客户您好，您所查询的产品为山东恩泽乳品有限公司生产的正牌“老广北”奶粉，请放心购买，感谢您的支持！
      </div>
      <div class="title title1" v-if="success==2">
         您所查询的数码已被重复查询多次，已失效，谨防假冒。
      </div>
      <div class="title title1" style="color:#E53333;font-weight:400" v-if="success==3">
         您查询的防伪溯源码{{ code }}，不存在！谨防假冒！
      </div>
      <div class="re-info" v-if="success==1">
          <p>查询数码：{{ code }}</p>
          <p>查询次数：{{ num }}</p>
          <p>查询时间：{{ time }}</p>
      </div>
    </div>
    <img v-if="codeImg&&success==1" :src="codeImg" alt="二维码" class="codeimg" srcset="">

  </div>
</template>

<script>
import wx from 'weixin-js-sdk';
const bkImg = require('../assets/bk.jpg');
export default {
    name: 'HelloWorld',
    data() {
        return {
            msg: 'nihao',
            bkImg: bkImg,
            time: '',
            num: '',
            code: '',
            codeImg: '',
            success: -1
        };
    },

    mounted() {
        const code = this.$route.query.code;
        if (code) {
            this.getCodeSuccess();
        } else {
            this.success = -2;
        }
    },
    methods: {
        getCodeSuccess() {
            this.httpGet(this.$root.codeSearch, { code: this.$route.query.code })
                .then(res => {
                    console.log(res);
                    const { time, code, number, success, codeImg } = res;
                    this.time = time;
                    this.code = code;
                    this.num = number;
                    this.success = success;
                    this.codeImg = codeImg;
                    if (this.success == 3) {
                        this.code = this.$route.query.code;
                    }
                });
        }

    }
};
</script>

<style scoped lang="stylus">
    @import '~@/common/main.styl'
    .content {
      height: 100vh;
      width 100vw;
      overflow-x: hidden;
      background: #fff;
      .bk{
        width 100vw;
      }

      .err-tiltle{
        width: vw(300)
        margin: 0 auto;
        word-vw(12px,#333);

      }
      .success{
        width: vw(325)
        margin: 0 auto;
        .title{
          word-vw(12px,#000);
          font-weight 600;
          line-height: 1.2rem;
          text-indent: 2rem;
          font-family: "思源黑体 CN Light", Helvetica, Arial, "Hiragino Sans GB", "Microsoft Yahei", "微软雅黑", STHeiti, "华文细黑", "Heiti SC", sans-serif;

        }
        .title1{
          text-indent: 0rem;
          text-align: center;

        }
      }

      .re-info{
        text-indent: 2rem;
        margin-top: vw(8);
        p{
          word-vw(12px,#333);
          line-height: 1.5;

        }
      }

      .codeimg{
        width:vw(100);
        display: block;
        margin: 0 auto;
        margin-top: vw(25)
      }
    }
</style>
